#ifndef _MY_STACK_H_
#define _MY_STACK_H_

#include "node.h"
#include <atomic>

template<typename T>
class my_stack {
	public:
		void push(const T& data);
		shared_ptr<T> pop();
		void afficher() const;
		~my_stack();
	private:
		static void deleteNodes(node<T>* nodes);
		void chainPendingNodes(node<T>* first, node<T>* last);
		void chainPendingNodes(node<T>* n);
		void chainPendingNode(node<T>* n);
		void tryReclaim(node<T>* oldHead);
		
		atomic<node<T>*> head;
		atomic<node<T>*> pendingNodes;
		atomic<unsigned int> nbInPops;
};

#include "my_stack.tcc"

#endif
